package com.cnhis.cloudhealth.clidoctorweb.doctoradviceinfo;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.logging.Logger;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cnhis.cloudhealth.clinical.clidoctor.doctoradviceinfo.service.IDoctorAdviceInfo;
import com.cnhis.cloudhealth.clinical.clidoctor.lucence.service.ILucenceService;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.interceptor.SpringContextHolder;
import com.cnhis.cloudhealth.commons.rediscache.CookieUtil;
import com.cnhis.cloudhealth.commons.redisdb.RedisResource;
import com.cnhis.cloudhealth.commons.utils.GlobalVariable;
import com.cnhis.cloudhealth.commons.utils.JsonUtil;

@Path("doctoradvice")
@Component
public class DoctorAdviceRest
{
    Logger log = Logger.getLogger(DoctorAdviceRest.class);
    
    @Reference
    private IDoctorAdviceInfo doctorAdvice;
    
    @Reference
    private ILucenceService lucenceService;
    
    private RedisResource redisResource = (RedisResource) SpringContextHolder.getBean("redisResource");
    
    /**
     * 检索门诊病人对应的医嘱信息 脚本 id 712
     * 
     * @return
     */
    @POST
    @Path("patientdoctoradviceinfo")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo patientDoctorAdviceInfo(@FormParam("currPage") int currPage, @FormParam("pageSize") int pageSize)
        throws Exception
    {
        HashMap hs = new HashMap();
        return doctorAdvice.patientDoctorAdviceInfo(hs, (currPage - 1) * pageSize, pageSize);
    }
    
    /**
     * 检索对应病人医嘱记录
     * 
     * @param lVAF06 就诊id
     * @param lVAF04 病人来源 门诊 住院
     * @param lBCE01A 开嘱医师id
     * @param currPage
     * @param pageSize
     * @param adate 日期 YYYY-MM-DD HH24:MI:SS
     * @return
     * @throws Exception 脚本id 792
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("getpatientsdoctoradvice")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getPatientsDoctorAdvice(@FormParam("lVAF06") long lVAF06, @FormParam("lVAF04") int lVAF04,
        @FormParam("lBCE01A") int lBCE01A, @FormParam("VAF74") String VAF74, @FormParam("VAF36") String VAF36,@FormParam("date1") String date1 ,
                                           @FormParam("date2") String date2,
                                           @FormParam("day") Integer day)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("lVAF06", lVAF06);
        hs.put("lVAF04", lVAF04);
        hs.put("lBCE01A", lBCE01A);
        hs.put("VAF36", VAF36 == null || "".equals(VAF36) ? "DESC" : VAF36.toUpperCase());
        hs.put("VAF74", VAF74 == null || "".equals(VAF74) ? "DESC" : VAF74.toUpperCase());
        hs.put("date1",date1);
        hs.put("date2",date2);
        hs.put("day",day);
        return doctorAdvice.getPatientsDoctorAdvice(hs);
    }
    
    /**
     * 检查对应病人是否有医嘱
     * 
     * @param vaf04 住院 门诊 1
     * @param vaa01 病人id
     * @param vaf06 就诊id
     * @param currPage
     * @param pageSize
     * @return
     * @throws Exception 脚本id 839
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("checkpatientdoctoradvice")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo checkPatientDoctorAdvice(@FormParam("vaf04") int vaf04, @FormParam("vaa01") long vaa01,
        @FormParam("vaf06") long vaf06)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("vaf04", 1);
        hs.put("vaa01", vaa01);
        hs.put("vaf06", vaf06);
        
        return doctorAdvice.checkPatientDoctorAdvice(hs);
    }
    /**
     * ScriptId(838) 
     * Description(检查病人是否还有未发送医嘱) 
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("checkPatientDoctorAdviceUnSend")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo checkPatientDoctorAdviceUnSend(@FormParam("vaf06") long vaf06)
            throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("vaf04", 1);
        hs.put("vaa10", 1);
        hs.put("vaf06", vaf06);
        return doctorAdvice.checkPatientDoctorAdviceUnSend(hs);
    }
    
    /**
     * Description(完成接诊服务) 
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("wanchengjiezhen")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo wanchengjiezhen(@FormParam("vac01") long vac01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("vac01", vac01);
        return doctorAdvice.wanchengjiezhen(hs);
    }
    
    /**
     * Description(取消完诊) 
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("quxiaowanzhen")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo quxiaowanzhen(@FormParam("vac01") long vac01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("vac01", vac01);
        return doctorAdvice.quxiaowanzhen(hs);
    }
    
    /**
     * 判断对应病人是否存在未作废医嘱
     * 
     * @param VAF04 住院 门诊 1
     * @param VAA01 病人id
     * @param VAF06 就诊id
     * @param currPage
     * @param pageSize
     * @return
     * @throws Exception 脚本id 1718
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("checkpatientcancellationdoctoradvice")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo checkPatientCancellationDoctorAdvice(@FormParam("VAF04") int VAF04, @FormParam("VAA01") int VAA01,
        @FormParam("VAF06") int VAF06, @FormParam("currPage") int currPage, @FormParam("pageSize") int pageSize)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("VAF04", VAF04);
        hs.put("VAA01", VAA01);
        hs.put("VAF06", VAF06);
        
        return doctorAdvice.checkPatientCancellationDoctorAdvice(hs, (currPage - 1) * pageSize, pageSize);
    }
    
    /**
     * 已计价检查医嘱记录
     * 
     * @param lVAFID
     * @param acf01
     * @param currPage
     * @param pageSize
     * @return
     * @throws Exception 脚本id 1762
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("valuationdoctoradvice")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo valuationDoctorAdvice(@FormParam("lVAFID") int lVAFID, @FormParam("acf01") int acf01,
        @FormParam("currPage") int currPage, @FormParam("pageSize") int pageSize)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("lVAFID", lVAFID);
        hs.put("acf01", acf01);
        
        return doctorAdvice.valuationDoctorAdvice(hs, (currPage - 1) * pageSize, pageSize);
    }
    
    /**
     * 用于检索门诊已结帐需要退费的医嘱
     * 
     * @param lVaf06 就诊id
     * @param lBCE01 开嘱医师id
     * @param lCheck
     * @param lMember
     * @param currPage
     * @param pageSize
     * @return
     * @throws Exception 脚本id 1554
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("returnpremiumdoctoradvice")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo returnPremiumDoctorAdvice(@FormParam("lVaf06") int lVaf06, @FormParam("lBCE01") int lBCE01,
        @FormParam("lCheck") int lCheck, @FormParam("lMember") int lMember, @FormParam("currPage") int currPage,
        @FormParam("pageSize") int pageSize)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("lVaf06", lVaf06);
        hs.put("lBCE01", lBCE01);
        hs.put("lCheck", lCheck);
        hs.put("lMember", lMember);
        return doctorAdvice.returnPremiumDoctorAdvice(hs, (currPage - 1) * pageSize, pageSize);
    }
    
    /**
     * 获取对应医嘱单类型
     * 
     * @param CBM01 医嘱id
     * @return
     * @throws Exception 脚本id 7234
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("getdoctoradvicetype")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getDoctorAdviceType(@FormParam("CBM01") int CBM01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("CBM01", CBM01);
        
        return doctorAdvice.getDoctorAdviceType(hs);
    }
    
    /* ScriptId(7502) */
    /* Description(医嘱单处方性质) */
    @POST
    @Path("getdoctoradviceprescriptionnature")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getDoctorAdvicePrescriptionNature()
        throws Exception
    {
        return doctorAdvice.getDoctorAdvicePrescriptionNature();
    }
    
    /* ScriptId(1176) */
    /* Description(对应医嘱单的医师诊断) */
    /**
     * 
     * @param lVAA01 诊断记录id
     * @param lVAE01 就诊id
     * @param lVAF01 医嘱单id
     * @param acf01 1 门诊 其他 住院
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("doctordiagnosis")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo doctorDiagnosis(
//        @FormParam("lVAA01") int lVAA01, @FormParam("lVAE01") int lVAE01,-------wj：去除原来不用的参数
        @FormParam("lVAF01") long lVAF01, @FormParam("acf01") long acf01)
        throws Exception
    {
        HashMap map = new HashMap();
//        map.put("lVAA01", lVAA01);
//        map.put("lVAE01", lVAE01);
        map.put("lVAF01", lVAF01);
        map.put("acf01", acf01);
        return doctorAdvice.doctorDiagnosis(map);
    }
    
    /* ScriptId(6418) */
    /* Description(门诊病人历次就诊医嘱记录) */
    /**
     * 
     * @param EmpID 员工id（bce01）
     * @param lVAA01 病人id
     * @param lVAF04 门诊 1
     * @param lCheck 0
     * @param productId
     * @param programId
     * @param paramNo
     * @return
     * @throws Exception(100,105002,233)
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("patientsuccessivedoctoradvicerecord")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo patientSuccessiveDoctorAdviceRecord(@FormParam("EmpID") int EmpID, @FormParam("lVAA01") long lVAA01,
        @FormParam("lVAF04") int lVAF04, @FormParam("lCheck") int lCheck, @FormParam("productid") int productid,
        @FormParam("programid") int programid, @FormParam("paramno") int paramno)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("EmpID", EmpID);
        hs.put("lCheck", lCheck);
        hs.put("lVAA01", lVAA01);
        hs.put("lVAF04", lVAF04);
        hs.put("productid", productid);
        hs.put("programid", programid);
        hs.put("paramno", paramno);
        return doctorAdvice.patientSuccessiveDoctorAdviceRecord(hs);
    }
    
    /* ScriptId(7300) */
    /* Description(获取病人咨询内容 ) */
    /**
     * 
     * @param SCF01 id
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("getpatientconsultcontent")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getPatientConsultContent(@FormParam("SCF01") int SCF01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("SCF01", SCF01);
        return doctorAdvice.getPatientConsultContent(hs);
    }
    
    /* ScriptId(1106) */
    /* Description(医疗项目跟类 ) */
    /**
     * 
     * @param productId
     * @param programId
     * @param paramNo (9999,9999,27)
     * @return
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    @POST
    @Path("medicalitemtype")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo medicalItemType(@FormParam("productId") int productId, @FormParam("programId") int programId,
        @FormParam("paramNo") int paramNo)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("productId", productId);
        hs.put("programId", programId);
        hs.put("paramNo", paramNo);
        return doctorAdvice.medicalItemType(hs);
    }
    /* ScriptId(7501) */
    
    /* Description(医嘱单处方属性) */
    /**
     * 
     * @param iaa01 机构id
     * @param acf01
     * @param cbm01 医嘱单id
     * @return
     * @throws Exception
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("doctoradviceprescriptionproperty")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo doctorAdvicePrescriptionProperty(@FormParam("iaa01") int iaa01, @FormParam("acf01") int acf01,
        @FormParam("vaf01") long vaf01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("iaa01", iaa01);
        hs.put("acf01", acf01);
        hs.put("vaf01", vaf01);
        return doctorAdvice.doctorAdvicePrescriptionProperty(hs);
    }
    
    /* ScriptId(1402) */
    /* Description(门诊医嘱单收费明细) */
    /**
     * 
     * @param lCBM01 医嘱单id
     * @param acf01
     * @return
     * @throws Exception
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    @POST
    @Path("doctoradvicedetail")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo doctorAdviceDetail(@FormParam("lCBM01") long lCBM01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("lCBM01", lCBM01);
        hs.put("acf01", 1);
        return doctorAdvice.doctorAdviceDetail(hs);
    }
    
    /* ScriptId(1405) */
    /* Description(门诊医嘱单显示发送记录) */
    /**
     * 
     * @param lCBM01 医嘱单id
     * @param currPage
     * @param pageSize
     * @return
     * @throws Exception
     */
    @POST
    @Path("sendadvicehistory")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings({"unchecked", "rawtypes"})
    public ModelVo sendAdviceHistory(@FormParam("lCBM01") long lCBM01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("lCBM01", lCBM01);
        return doctorAdvice.sendAdviceHistory(hs);
    }
    
    /* ScriptId(1405) */
    /* Description(门诊医嘱单显示发送记录) */
    /**
     * 
     * @param lCBM01 医嘱单id
     * @param currPage
     * @param pageSize
     * @return
     * @throws Exception
     */
    @POST
    @Path("sendadvicehistory_vaf")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings({"unchecked", "rawtypes"})
    public ModelVo sendadvicehistory_vaf(@FormParam("vaf01") long vaf01,@FormParam("cbm01") long cbm01,@FormParam("date1") String date1 ,
                                         @FormParam("date2") String date2)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("date1", date1);
        hs.put("date2", date2);
        hs.put("vaf01", vaf01);
        hs.put("cbm01", cbm01);
        return doctorAdvice.sendadvicehistory_vaf(hs);
    }
    
    /* ScriptId(7299) */
    /* Description(医师站手术人员安排查询) */
    /**
     * 
     * @param VAF01 医嘱id
     * @return
     * @throws Exception
     */
    @POST
    @Path("queryoperationscheduled")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo queryOperationScheduled(@FormParam("VAF01") long VAF01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("VAF01", VAF01);
        return doctorAdvice.queryOperationScheduled(hs);
    }
    
    /* ScriptId(844) */
    /* Description(门诊新开医嘱计价内容：西、成药) */
    /**
     * 
     * @param lVAF01 医嘱单id
     * @param lVAF01A
     * @param ABC02
     * @param aDate 日期 YYYY-MM-DD
     * @return
     * @throws Exception
     */
    @POST
    @Path("querydoctoradvicepricecontent")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo queryDoctorAdvicePriceContent(@FormParam("lVAF01") long lVAF01, @FormParam("lVAF01A") long lVAF01A,
        @FormParam("ABC02") String ABC02, @FormParam("aDate") String aDate)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("lVAF01", lVAF01);
        hs.put("lVAF01A", lVAF01A);
        hs.put("ABC02", ABC02);
        hs.put("aDate", aDate);
        return doctorAdvice.queryDoctorAdvicePriceContent(hs);
        
    }
    /* ScriptId(7369) */
    /* Description(获取医嘱执行性质) */
    @POST
    @Path("doctoradviceexecuteproperty")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo doctorAdviceExecuteProperty(@FormParam("asign") int asign)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("asign", asign);
      //加载redis数据
//        return redisResource.getRedisModelVo("zhixingxingzhi_mz");
        return doctorAdvice.doctorAdviceExecuteProperty(hs);
    }
    
    /* ScriptId(1349) */
    /* Description(门诊按医嘱单显示医嘱对应计价信息,新下达医嘱) */
    /**
     * 
     * @param lCBM01 医嘱单id
     * @param aDate 日期 YYYY-MM-DD HH24:MI:ss
     * @param ABC02 病人费别
     * @return
     * @throws Exception
     */
    @POST
    @Path("doctoradvicepriceinfo")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo doctorAdvicePriceInfo(@FormParam("lCBM01") long lCBM01, @FormParam("ABC02") String ABC02)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("lCBM01", lCBM01);
        hs.put("ABC02", ABC02);
        return doctorAdvice.doctorAdvicePriceInfo(hs);
    }
    /* ScriptId(7503) */
    /* Description(修改医嘱单时，提取对应处方医疗类别) */
    
    /**
     * 医嘱单id
     * 
     * @param CBM01
     * @return
     * @throws Exception
     */
    @GET
    @Path("medicaltype")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo medicalType(@QueryParam("CBM01") long CBM01)
        throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("CBM01", CBM01);
        return doctorAdvice.medicalType(hs);
    }
    
    /* ScriptId(1761) */
    /* Description(新开医嘱时，提取对应检查医嘱的费用明细) */
    @POST
    @Path("inspectionadvicefeedetail")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo inspectionAdviceFeeDetail(@FormParam("lVAF06") long lVAF06, @FormParam("lBBX01") int lBBX01,
        @FormParam("lVAF21") String lVAF21, @FormParam("ACF01") int ACF01, @FormParam("lVAF22") String lVAF22,
        @FormParam("lBCK03") String lBCK03, @FormParam("lBDU07") int lBDU07, @FormParam("lBDU08") String lBDU08,
        @FormParam("lBDU09") String lBDU09, @FormParam("BDA01") String BDA01, @FormParam("lBCK01A") int lBCK01A,
        @FormParam("aDate") String aDate, @FormParam("VAF17") int VAF17, @FormParam("VAF26") String VAF26,
        @FormParam("VAF27") int VAF27, @FormParam("VAF28") int VAF28, @FormParam("VAF29") String VAF29,
        @FormParam("vaj26") int vaj26, @FormParam("vaj27") int vaj27, @FormParam("vaf58") int vaf58)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("lVAF06", lVAF06);
        map.put("lBBX01", lBBX01);
        map.put("lVAF21", lVAF21);
        map.put("ACF01", ACF01);
        map.put("lVAF22", lVAF22);
        map.put("lBCK03", lBCK03);
        map.put("lBDU07", lBDU07);
        map.put("lBDU08", lBDU08);
        map.put("lBDU09", lBDU09);
        map.put("BDA01", BDA01);
        map.put("lBCK01A", lBCK01A);
        map.put("aDate", new SimpleDateFormat("YYYY-MM-dd").format(new Date()));
        map.put("VAF17", VAF17);
        map.put("VAF18", "1");
        map.put("VAF26", VAF26);
        map.put("VAF27", VAF27);
        map.put("VAF28", VAF28);
        map.put("VAF29", VAF29);
        map.put("vaj26", vaj26);
        map.put("vaj27", vaj27);
        map.put("vaf58", vaf58);
        return doctorAdvice.inspectionAdviceFeeDetail(map);
    }
    
    /* ScriptId(7311) */
    /* Description(判断医嘱业务范围) */
    @GET
    @Path("advicebusinessscope")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo adviceBusinessScope(@QueryParam("VAF01") long VAF01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("VAF01", VAF01);
        return doctorAdvice.adviceBusinessScope(map);
    }
    
    /* ScriptId(7370) */
    /* Description(获取单独条码项目) */
    /**
     * BBX01 id
     * 
     */
    @GET
    @Path("getbarcode")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo getBarCode(@QueryParam("BBX01") int BBX01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("BBX01", BBX01);
        return doctorAdvice.getBarCode(map);
    }
    
    /* ScriptId(1452) */
    /* Description(判断对应检查项目是否有对应检查部位) */
    /**
     * 
     * @param BBX01 项目id
     * @param BBC01 影像诊疗类型
     * @return
     */
    @POST
    @Path("hasinspectionbody")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo hasInspectionBody(@FormParam("BBX01") int BBX01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("BBX01", BBX01);
        return doctorAdvice.hasInspectionBody(map);
    }
    
    /* ScriptId(1766) */
    /* Description(提取对应检查类型的检查部位及分类) */
    /**
     * 
     * @param BBC01 类型
     * @return
     * @throws Exception
     */
    @POST
    @Path("getcheckbodybyid")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo getCheckBodyById(@FormParam("BBC01") String BBC01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("BBC01", BBC01);
        return doctorAdvice.getCheckBodyById(map);
    }
    
    /* ScriptId(1456) */
    /* Description(检查项目对应身体部位) */
    /**
     * 
     * @param BBX01 项目id
     * @param BBC01 影像诊疗类型
     * @return
     * @throws Exception
     */
    @POST
    @Path("getcheckbody")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo getCheckBody(@FormParam("BBX01") int BBX01, @FormParam("BBC01") String BBC01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("BBC01", BBC01);
        return doctorAdvice.getCheckBody(map);
    }
    
    /* ScriptId(1765) */
    /* Description(检查项目对应 检查部位 对应检查方法) */
    /**
     * 
     * @param BBX01 项目id
     * @param BBC01 影像类型
     * @param BCI06 检查部位
     * @return
     * @throws Exception
     */
    @POST
    @Path("getcheckbodymethod")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo getCheckBodymethod(@FormParam("BBX01") int BBX01, @FormParam("BBC01") String BBC01,
        @FormParam("BCI06") String BCI06)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("BBX01", BBX01);
        map.put("BBC01", BBC01);
        map.put("BCI06", BCI06);
        return doctorAdvice.getCheckBodymethod(map);
    }
    
    /* ScriptId(7338) */
    /* Description(下达医嘱时，获取医嘱组合明细) */
    /**
     * 
     * @param bbx01
     * @param ACF01
     * @return
     * @throws Exception
     */
    @POST
    @Path("combineddetail")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo combinedDetail(@FormParam("bbx01") int bbx01, @FormParam("ACF01") int ACF01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("bbx01", bbx01);
        map.put("ACF01", ACF01);
        return doctorAdvice.combinedDetail(map);
    }
    
    /* ScriptId(961) */
    /* Description(判断对应病人是否有对应状态的医嘱) */
    /**
     * 
     * @param lType
     * @param lVAF06 就诊id
     * @param lVAF04 1 or 2
     * @param BCE01 开嘱医师或者操作者id
     * @return
     * @throws Exception
     */
    @POST
    @Path("patientadvicestate")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo patientAdviceState(@FormParam("lType") int lType, @FormParam("lVAF06") int lVAF06,
        @FormParam("lVAF04") int lVAF04, @FormParam("BCE01") int BCE01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("lType", lType);
        map.put("lVAF06", lVAF06);
        map.put("lVAF04", lVAF04);
        map.put("BCE01", BCE01);
        return doctorAdvice.patientAdviceState(map);
        
    }
    
    /* ScriptId(1143) */
    /* Description(提取病人历史医嘱记录) */
    /**
     * 
     * @param vaa01 病人id
     * @param acf01
     * @return
     * @throws Exception
     */
    @POST
    @Path("queryadvicehistory")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo queryAdviceHistory(@FormParam("vaa01") int vaa01, @FormParam("acf01") int acf01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("vaa01", vaa01);
        map.put("acf01", acf01);
        return doctorAdvice.queryAdviceHistory(map);
    }
    
    /* ScriptId(7363) */
    /* Description(提取医嘱历史记录) */
    /**
     * 
     * @param lCBM01 医嘱id
     * @param lBCK01A 部门id
     * @param lVAA01 病人id
     * @param lVAF06 就诊id
     * @param lVAF07
     * @param lMode
     * @param lVAF01
     * @param ACF01
     * @param adate
     * @param CBMid
     * @param lVAF01A
     * @return
     * @throws Exception
     */
    @POST
    @Path("doctoradvicehistory")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo doctorAdviceHistory(@FormParam("lCBM01") int lCBM01, @FormParam("lBCK01A") int lBCK01A,
        @FormParam("lVAA01") int lVAA01, @FormParam("lVAF06") int lVAF06, @FormParam("lVAF07") int lVAF07,
        @FormParam("lMode") int lMode, @FormParam("lVAF01") int lVAF01, @FormParam("ACF01") int ACF01,
        @FormParam("adate") String adate, @FormParam("CBMid") int CBMid, @FormParam("lVAF01A") int lVAF01A)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("lCBM01", lCBM01);
        map.put("lBCK01A", lBCK01A);
        map.put("lVAA01", lVAA01);
        map.put("lVAF06", lVAF06);
        map.put("lVAF07", lVAF07);
        map.put("lMode", lMode);
        map.put("lVAF01", lVAF01);
        map.put("ACF01", ACF01);
        map.put("adate", adate);
        map.put("CBMid", CBMid);
        map.put("lVAF01A", lVAF01A);
        return doctorAdvice.doctorAdviceHistory(map);
    }
    
    /* ScriptId(7325) */
    /* Description(检索单个卫材医嘱项目) */
    @POST
    @Path("queryguard")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo queryGuard(@FormParam("lBBY01") int lBBY01, @FormParam("lBCT33") int lBCT33)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("lBBY01", lBBY01);
        map.put("lBCT33", lBCT33);
        return doctorAdvice.queryGuard(map);
    }
    
    /**
     * 7295
     * 皮试药物对应皮试项目
     * @return
     * @throws Exception
     */
    @GET
    @Path("queryBbxByBdt")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings({"unchecked", "rawtypes"})
    public ModelVo queryBbxByBdt(@QueryParam("bbx01a") long bbx01a)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("bbx01a", bbx01a);
        return doctorAdvice.queryBbxByBdt(map);
    }
    
    /**
     * 分诊台叫号外显
     * @return
     * @throws Exception
     */
    @GET
    @Path("queryJiaohaoList")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings({"rawtypes"})
    public ModelVo queryJiaohaoList(@Context HttpServletRequest request,@Context HttpServletResponse response)
        throws Exception
    {
        String user = request.getParameter("user");
        HashMap map = new HashMap();
        return doctorAdvice.queryJiaohaoList(map);
    }
    
    /**
     * 初始化lucence索引文件
     * @return
     * @throws Exception
     */
    @GET
    @Path("initLucenceIndex")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings({"unchecked", "rawtypes"})
    public Map initLucenceIndex(@QueryParam("params") String params,@Context HttpServletRequest request)
    {
        HashMap map = new HashMap();
        Map temp = JsonUtil.getMap(params);
        try
        {
            lucenceService.initIndex(temp);
            map.put("result", "Success");
        }
        catch (Exception e)
        {
            e.printStackTrace();
            map.put("result", "Failure");
        }
        return map;
    }
    
    /**
     * 增加lucence索引文件
     * @return
     * @throws Exception
     */
    @POST
    @Path("addLucenceIndex")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings({"unchecked", "rawtypes"})
    public Map addLucenceIndex(@FormParam("jsonList") String jsonList)
    {
        HashMap map = new HashMap();
        try
        {
            List<Map<String, Object>> list = JsonUtil.getList(jsonList);
            lucenceService.addIndex(list);
            map.put("result", "Success");
        }
        catch (Exception e)
        {
            map.put("result", "Failure");
            e.printStackTrace();
        }
        return map;
    }
    
    /**
     * 医嘱智能搜索
     * @return
     * @throws Exception
     */
    @POST
    @Path("queryAdviceBySolr")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo queryAdviceBySolr(@FormParam("params") String params,@Context HttpServletRequest request) throws Exception
    {
        Map<String, Object> paramsObj = JsonUtil.getMap(params);
        String dbtype = "";
        if ("集团化".equals("集团化测试"))
        {
            String sid = CookieUtil.getCookieValue(request, "jsessionids");
            dbtype = (String)redisResource.opsForValueGet("db" + sid);
        }
        paramsObj.put("q", paramsObj.get("q")+" AND corporationid:"+dbtype+paramsObj.get("yiyuanId"));
        log.info("q======================="+paramsObj.get("q"));
        return lucenceService.queryAdviceBySolr(paramsObj);
    }
    
}
